package my.webservices.endpoint;

import my.webservices.VehicleHistoryService;
import my.webservices.beans.Request;
import my.webservices.beans.Response;
import my.webservices.beans.VehicleHistorySearchRequest;
import my.webservices.beans.VehicleHistorySearchResponse;

import org.jdom.JDOMException;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint;


/**
 * VhsEndPoint is the end point for vehicle history service.
 * 
 * @author Nilaksh Bajpai.
 */
public class VhsEndPoint extends AbstractMarshallingPayloadEndpoint {

  /**
   * Vehicle history search service.
   */
  private final VehicleHistoryService vehicleHistorySearchService;

  /**
   * Constructor.
   * 
   * @param vehicleHistorySearchService
   * @param marshaller
   * @throws JDOMException
   */
  public VhsEndPoint(final VehicleHistoryService vehicleHistorySearchService, final Marshaller marshaller,
      final Unmarshaller unmarshaller) throws JDOMException {
    super(marshaller, unmarshaller);
    this.vehicleHistorySearchService = vehicleHistorySearchService;
  }

  /**
   * @see org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint#invokeInternal(java.lang.Object)
   *      .
   */
  @Override
  protected Object invokeInternal(final Object request) throws Exception {
    Request input = (Request) request;
    Response response = input.visit(vehicleHistorySearchService);
    return response;
  }
}
